#include <iostream>
#include <vector>
using namespace std;

class Solution {
public:
  pair<int, int> singleNumber(vector<int> &nums) {
    int re = 0;
    for (auto num : nums) {
      re ^= num;
    }
    // 此时 re 的值为唯二两个奇数次数的异或
    int x = re & (~re + 1);
    int a = 0;
    for (auto num : nums) {
      // 如何保证 num 的该位为 1，只需要让其相与，如果和 x 向相等，则该位为 1
      if ((num & x) == x) {
        a ^= num;
      }
    }
    return pair<int, int>(a, re ^ a);
  }
};

int main() {
  vector<int> v{1, 2, 2, 3};
  auto x = (new Solution)->singleNumber(v);
  cout << x.first << " " << x.second << endl;
}